<?php echo $header; ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('view/image/shipping.png');"><?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
  </div>
  <div class="content">
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <table class="form">
        <tr>
          <td><span class="required">*</span> <?php echo $entry_name; ?></td>
          <td><input name="name" value="<?php echo $name; ?>" size="100" />
            <?php if ($error_name) { ?>
            <span class="error"><?php echo $error_name; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td><?php echo $entry_sort_order; ?></td>
          <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
        </tr>                
        <tr>
          <td><?php echo $entry_image; ?></td>
          <td>
            <div class="manufacturer_logo">
                <div class="title"><?php echo $entry_logo; ?></div>
                <div>
                    <input type="hidden" name="logo" value="<?php echo $logo; ?>" id="logo" />
                    <img src="<?php echo $preview_logo; ?>" alt="" id="preview_logo" class="image" onclick="image_upload('logo', 'preview_logo');" />            
                </div>
            </div>
            <div class="manufacturer_image">
                <div class="title">Image 1:</div>
                <div>
                    <input type="hidden" name="image" value="<?php echo $image; ?>" id="image" />
                    <img src="<?php echo $preview; ?>" alt="" id="preview" class="image" onclick="image_upload('image', 'preview');" />
                </div>
            </div>
            <div class="manufacturer_image">
                <div class="title">Image 2:</div>
                <div>
                    <input type="hidden" name="image1" value="<?php echo $image1; ?>" id="image1" />
                    <img src="<?php echo $preview1; ?>" alt="" id="preview1" class="image" onclick="image_upload('image1', 'preview1');" />
                </div>
            </div>
            <div class="manufacturer_image">
                <div class="title">Image 3:</div> 
                <div>
                    <input type="hidden" name="image2" value="<?php echo $image2; ?>" id="image2" />
                    <img src="<?php echo $preview2; ?>" alt="" id="preview2" class="image" onclick="image_upload('image2', 'preview2');" />
                </div>
            </div>
            <div class="manufacturer_image">
                <div class="title">Image 4:</div> 
                <div>
                    <input type="hidden" name="image3" value="<?php echo $image3; ?>" id="image3" />
                    <img src="<?php echo $preview3; ?>" alt="" id="preview3" class="image" onclick="image_upload('image3', 'preview3');" />
                </div>
            </div>
          </td>
        </tr>  
        <tr>
          <td>Title:</td>
          <td><input name="title" value="<?php echo $title; ?>" size="100" />
        </tr>
        <tr>
          <td><?php echo $entry_description; ?></td>
          <td><textarea name="description" id="description"><?php echo $description; ?></textarea></td>
        </tr>         
        <tr style="display:none;">
          <td><?php echo $entry_store; ?></td>
          <td><div class="scrollbox">
              <?php $class = 'even'; ?>
              <div class="<?php echo $class; ?>">
                <?php if (in_array(0, $manufacturer_store)) { ?>
                <input type="checkbox" name="manufacturer_store[]" value="0" checked="checked" />
                <?php echo $text_default; ?>
                <?php } else { ?>
                <input type="checkbox" name="manufacturer_store[]" value="0" />
                <?php echo $text_default; ?>
                <?php } ?>
              </div>
              <?php foreach ($stores as $store) { ?>
              <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
              <div class="<?php echo $class; ?>">
                <?php if (in_array($store['store_id'], $manufacturer_store)) { ?>
                <input type="checkbox" name="manufacturer_store[]" value="<?php echo $store['store_id']; ?>" checked="checked" />
                <?php echo $store['name']; ?>
                <?php } else { ?>
                <input type="checkbox" name="manufacturer_store[]" value="<?php echo $store['store_id']; ?>" />
                <?php echo $store['name']; ?>
                <?php } ?>
              </div>
              <?php } ?>
            </div></td>
        </tr>
        <tr>
          <td>Status:</td>
          <td>
              <select name="status">
                <?php if ($status) { ?>
                    <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                    <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                    <option value="1"><?php echo $text_enabled; ?></option>
                    <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select>
          </td>
        </tr>
        <tr>
            <td><?php echo $entry_meta_title;?></td>
            <td><input type="text" name="meta_title" value="<?php echo $meta_title; ?>"  size="100" /></td>
        </tr>           
        <tr>
            <td><?php echo $entry_meta_keywords;?></td>
            <td><textarea name="meta_keywords" cols="40" rows="5"><?php echo $meta_keywords; ?></textarea></td>
        </tr>
        <tr>
            <td><?php echo $entry_meta_description; ?></td>
            <td><textarea name="meta_description" cols="40" rows="5"><?php echo $meta_description; ?></textarea></td>
        </tr>  
        <tr>
          <td><?php echo $entry_keyword; ?></td>
          <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" size="100" /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.draggable.js"></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.resizable.js"></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.dialog.js"></script>
<script type="text/javascript" src="view/javascript/jquery/ui/external/bgiframe/jquery.bgiframe.js"></script>
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>

<script type="text/javascript"><!--
CKEDITOR.replace('description', {
    filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
//--></script>

<script type="text/javascript"><!--
function image_upload(field, preview) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>',
					type: 'POST',
					data: 'image=' + encodeURIComponent($('#' + field).val()),
					dataType: 'text',
					success: function(data) {
						$('#' + preview).replaceWith('<img src="' + data + '" alt="" id="' + preview + '" class="image" onclick="image_upload(\'' + field + '\', \'' + preview + '\');" />');
                        
                        if(data.indexOf('no_image') > 0){                             
                            $('#' + field).attr('value', '');
                        }
					}
				});
			}
		},	
		bgiframe: false,
		width: 700,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script>
<?php echo $footer; ?>